package bl;

import java.util.ArrayList;

import db.DataShowOperate;
import db.DatabaseFactory;
import dbservice.DatabaseService;
import dbservice.FactoryService;
import po.AttributeEnum;
import po.StrategyPO;
import blservice.StrategyBLService;

public class StrategyBLImpl implements StrategyBLService{
	
	private FactoryService dbService = DatabaseFactory.getDatabase();  
	@Override
	public int insertStrategy(String module, AttributeEnum courseAttribute,
			String courseType, int courseTypeTerm, int typeCredits) {
		// TODO Auto-generated method stub
		DatabaseService<StrategyPO> strategyDB = dbService.getStrategyDatabase();
		StrategyPO strategyPO = new StrategyPO(module,courseAttribute,courseType,courseTypeTerm,typeCredits );
		
		
		return strategyDB.insert(strategyPO);
	}
//	@Override
//	public StrategyPO show() {
//		// TODO Auto-generated method stub
//		DatabaseService<StrategyPO> strategyDB = dbService.getStrategyDatabase();
//		
//		
//		return strategyDB.show();
//	}
	@Override
	public ArrayList<StrategyPO> show() {
		// TODO Auto-generated method stub
		
		ArrayList<StrategyPO> strategyshow = new ArrayList<>();
		DataShowOperate dataShowOperate = dbService.getShowOperate();
		strategyshow  = dataShowOperate.showStrategy();
		return strategyshow;
	}
	@Override
	public int deleteStrategy(int id) {
		// TODO Auto-generated method stub
		DatabaseService<StrategyPO> strategyDB = dbService.getStrategyDatabase();
		
		
		return strategyDB.delete(id);
	}
	@Override
	public int updateStrategy(int strategyID, String module,
			AttributeEnum courseAttribute, String courseType,
			int courseTypeTerm, int typeCredits) {
		// TODO Auto-generated method stub
		
		DatabaseService<StrategyPO> strategyDB = dbService.getStrategyDatabase();
		StrategyPO strategyPO = new StrategyPO(strategyID,module,courseAttribute,courseType,courseTypeTerm,typeCredits );
		
		
		return strategyDB.update(strategyPO);
	}

}
